
function proxy(vm, target, key) {
  Object.defineProperty(vm, key, {
    get() {
      // vm.xxx -> vm.$data.xxx
      return vm[target][key];
    },
    set(newVal) {
      if (vm[target][key] === newVal) return;
      vm[target][key] = newVal;
    }
  })
}

function setConstantProperty(data, key, value) {
  Object.defineProperty(data, key, {
    value,
    enumerable: false,
    configurable: false
  });
}

function isObject(target) {
  return typeof target === 'object' && target !== null;
}

function isArray(target) {
  return Array.isArray(target);
}

export {
  proxy,
  setConstantProperty,
  isObject,
  isArray
}